package com.example.mygrade.webapi;

import com.example.mygrade.core.RUtil;
import com.example.mygrade.domain.SubjectCompare;
import com.example.mygrade.domain.SubjectStatic;
import com.example.mygrade.service.SubjectCompareService;
import com.example.mygrade.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/webapi/subjectcompare")
public class SubjectCompareController {
    @Autowired
    SubjectCompareService subjectCompareService;

    @GetMapping("/score")
    public List<SubjectCompare> getList(){
        return subjectCompareService.findAll();
    }

    @PostMapping("/getscore")
    public R getScore(String mid, Integer gradeid, String cname){
        List<SubjectCompare> subject = subjectCompareService.findByMidAndGradeidAndCname(mid,gradeid,cname);
        if (subject.size() > 0){
            return RUtil.success(subject,"获取信息成功");
        }else {
            return RUtil.error(405,"暂无信息");
        }

    }
}
